import { defineConfig } from "eslint/config";
import globals from "globals";
import js from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import pluginVue from "eslint-plugin-vue";

export default defineConfig({
  ignores: [
    "**/node_modules/**",
    "**/dist/**",
    "**/.git/**"
  ],
  rules: {
    "vue/no-multiple-template-root": "off",
    "vue/no-v-html": "off",
    "vue/no-v-text": "off",
    "vue/no-v-text-v-html-on-component": "off",
    "vue/no-v-model-argument": "off",
    "vue/no-v-for-template-key": "off",
    "no-var": "off",
    "vue/no-multiple-empty-lines": ["warn", { max: 1 }],
    "vue/no-console": process.env.NODE_ENV === "production" ? "error" : "off",
    "vue/no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
    "vue/no-unexpected-multiline": "error",
    "vue/no-useless-escape": "off",
    // typescript-eslint
    "no-unused-vars": "error",
    "prefer-ts-expect-error": "error",
    "no-explicit-any": "off",
    "no-non-null-assertion": "off",
    "no-namespace": "off",
    "semi": "off",
    // eslint-plugin-vue
    "vue/multi-word-component-names": "off",
    "vue/script-setup-uses-vars": "error",
    "vue/no-mutating-props": "off",
    "vue/attribute-hyphenation": "off"
  },
  overrides: [
    {
      files: ["**/*.{js,mjs,cjs,ts,vue}"],
      languageOptions: {
        globals: globals.browser
      }
    },
    {
      files: ["**/*.{js,mjs,cjs,ts,vue}"],
      plugins: {
        js
      },
      extends: ["js/recommended"]
    },
    {
      ...tseslint.configs.recommended,
      files: ["**/*.{ts,tsx}"]
    },
    {
      ...pluginVue.configs["flat/essential"],
      files: ["**/*.vue"]
    },
    {
      files: ["**/*.vue"],
      languageOptions: {
        parserOptions: {
          parser: tseslint.parser
        }
      }
    },
    {
      files: ["**/*.vue"],
      extends: ["plugin:vue/vue3-recommended"]
    }
  ]
});
